﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:markup="clr-namespace:Elysium.Markup"
                    xmlns:params="clr-namespace:Elysium.Parameters">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/Themes/SharedResources.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type ContextMenu}">
        <Setter Property="Background" Value="{markup:ThemeResource BackgroundBrush}"/>
        <Setter Property="BorderBrush" Value="{markup:ThemeResource HighlightBrush}"/>
        <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultThickness), Mode=OneWay}"/>
        <Setter Property="params:MenuBase.SubmenuBackground" Value="{Binding RelativeSource={RelativeSource Self}, Path=Background, Mode=OneWay}"/>
        <Setter Property="params:MenuBase.SubmenuBorderBrush" Value="{Binding RelativeSource={RelativeSource Self}, Path=BorderBrush, Mode=OneWay}"/>
        <Setter Property="params:MenuBase.SubmenuBorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=BorderThickness, Mode=OneWay}"/>
        <Setter Property="Foreground" Value="{markup:ThemeResource ForegroundBrush}"/>
        <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.ContentFontSize), Mode=OneWay}"/>
        <Setter Property="FontStretch" Value="Medium"/>
        <Setter Property="FontStyle" Value="Normal"/>
        <Setter Property="FontWeight" Value="Normal"/>
        <Setter Property="TextOptions.TextFormattingMode" Value="Display"/>
        <Setter Property="TextOptions.TextRenderingMode" Value="ClearType"/>
        <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled"/>
        <Setter Property="HasDropShadow" Value="{DynamicResource {x:Static SystemParameters.DropShadowKey}}"/>
        <Setter Property="params:General.ShadowBrush" Value="{markup:ThemeResource BackgroundContrastBrush}"/>        
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Grid.IsSharedSizeScope" Value="True"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}"/>
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ContextMenu}">
                    <Border x:Name="LayoutRoot">
                        <Border Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                TextBlock.Foreground="{TemplateBinding Foreground}"
                                TextBlock.FontFamily="{TemplateBinding FontFamily}"
                                TextBlock.FontSize="{TemplateBinding FontSize}"
                                TextBlock.FontStretch="{TemplateBinding FontStretch}"
                                TextBlock.FontStyle="{TemplateBinding FontStyle}"
                                TextBlock.FontWeight="{TemplateBinding FontWeight}"
                                TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}"
                                TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}"
                                RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                            <ItemsPresenter KeyboardNavigation.DirectionalNavigation="Cycle"/>
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="HasDropShadow" Value="True">
                            <Setter TargetName="LayoutRoot" Property="Effect">
                                <Setter.Value>
                                    <DropShadowEffect Color="{Binding RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}, Path=(params:General.ShadowBrush).(SolidColorBrush.Color)}"
                                                      BlurRadius="4" ShadowDepth="2"
                                                      Direction="315"
                                                      Opacity="0.3"/>
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="LayoutRoot" Property="Background" Value="{markup:ThemeResource TransparentBrush}"/>
                            <Setter TargetName="LayoutRoot" Property="Padding" Value="0,0,6,6"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FontSize, Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
                <Setter Property="TextOptions.TextFormattingMode" Value="Ideal"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>